#include "launch/env_parser.h"
#include "utils/common_utils.h"
#include "logger.h"

EnvParser::EnvParser()
{}
bool EnvParser::parser(const tinyxml2::XMLElement *element)
{
    //name
    const char *keyAttribute;
    tinyxml2::XMLError xmlError = element->QueryAttribute("name", &keyAttribute);
    if (tinyxml2::XMLError::XML_SUCCESS != xmlError)
    {
        ROS_ERROR("env get name attribute fail");
        return false;
    }
    //value
    const char *valueAttribute;
    xmlError = element->QueryAttribute("value", &valueAttribute);
    if (tinyxml2::XMLError::XML_SUCCESS != xmlError)
    {
        ROS_ERROR("env get value attribute fail");
        return false;
    }
    CommonUtils::setEnv(keyAttribute, valueAttribute);
    ROS_INFO("set env， %s:%s", keyAttribute, valueAttribute);
    return true;
}
